<?php
namespace jy_nongren;
defined('BY_JYA') or exit('error');
/*
	任务
*/
class task extends \plugin{
    public function upmyji($setting=array()){
		if($setting){
			$this->setting=$setting;
		}
        $daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
		//平台投喂
        $list = pdo_getall('jy_nongren_myji',array('uniacid'=>$_SESSION['uniacid'],'isweitou'=>1,'weitime <'=>$daytime));
		$lsfee=$this->setting['dj_dayls']?:100;
        foreach($list as $item){
			$this->model('model')->getls_renwu(-2,$lsfee);
			pdo_update('jy_nongren_myji',array('weitime'=>time(),'lsfee +='=>$lsfee,'lsday +='=>1),array('id'=>$item['id'],'uniacid'=>$_SESSION['uniacid']));
        }
		//饿死
		$day5time=$daytime-5*24*3600;
		pdo_update('jy_nongren_myji',array('status'=>3),array('uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2),'weitime <'=>$day5time));
		//饥饿
		$day3time=$daytime-3*24*3600;
		pdo_update('jy_nongren_myji',array('status'=>2),array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'weitime <'=>$day3time));
		//生蛋
		$dj_danday=$this->setting['dj_danday']?:30;
		$list = pdo_getall('jy_nongren_myji',array('uniacid'=>$_SESSION['uniacid'],'lsday >='=>$dj_danday,'status'=>1,'jdtime <'=>$daytime));
		foreach($list as $item){
			$this->model('model')->addjilog($item,4);
		}
        return true;
    }
}